/**
 * @author 黄波
 * 创建日期：2011Oct 10, 2011
 * TODO// N/A
 */
package com.platform.njcc.action;

import java.util.ArrayList;
import java.util.List;

import com.platform.bean.PageBean;
import com.platform.pojo.ResInfo;
import com.platform.pojo.ResReviews;
import com.platform.res.bean.ResReviewsBean;
import com.platform.res.bo.ResBo;
import com.platform.user.bo.UserBo;

/**
 * 根据资源ID,查询对应的所有评论信息
 */
public class GetReviewsAction extends NJCCSuport {

	private String resId;
	private List<ResReviewsBean> reviews = new ArrayList<ResReviewsBean>();
	private PageBean pageBean;
	private ResInfo res;
	
	public ResInfo getRes() {
		return res;
	}


	public void setRes(ResInfo res) {
		this.res = res;
	}


	@Override
	public String execute() throws Exception {
		ResBo resBo = ResBo.getInstance();
		UserBo userBo = UserBo.getInstance();
		res = resBo.getInfo(resId);
		Object[] objs = resBo.getResReviewsList(resId, pageBean);
		pageBean = (PageBean) objs[0];
		List<ResReviews> resReviews = (List<ResReviews>)objs[1];
		if(resReviews != null) {
			for(ResReviews item : resReviews) {
				ResReviewsBean bean = new ResReviewsBean();
				bean.setReview(item);
				bean.setUser(userBo.getUser(item.getUserId().toString()));
				bean.setRes(res);
				reviews.add(bean);
			}
		}
		return SUCCESS;
	}


	public PageBean getPageBean() {
		return pageBean;
	}

	public void setPageBean(PageBean pageBean) {
		this.pageBean = pageBean;
	}

	
	public String getResId() {
		return resId;
	}
	public void setResId(String resId) {
		this.resId = resId;
	}
	public List<ResReviewsBean> getReviews() {
		return reviews;
	}
	public void setReviews(List<ResReviewsBean> reviews) {
		this.reviews = reviews;
	}
	
}
